﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Infrastructure.Dto.Response.Epaylinks;

namespace WCS.Infrastructure.Dto.Request.Epaylinks
{

    /// <summary>
    /// 新增订单退款记录请求对象
    /// </summary>
    public class AddOrderRefundRecordRequestDto
    {
        /// <summary>
        /// 订单Id
        /// </summary>
        public string OrderId { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }

        /// <summary>
        /// 退款金额
        /// </summary>
        public long RefundAmount { get; set; }
    }

    /// <summary>
    /// 退款请求对象
    /// </summary>
    public class RefundRequest
    {
        /// <summary>
        /// 商户编号
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 商户退款单号（退款单号，代表本次退款申请交易，此退款单号在商户门户中展现为退款申请号，在对账单中则作为商户退款单号字段。丌允许使用相同癿退款单号发起多次退款请求。）
        /// </summary>
        public string OutRefundNo { get; set; }

        /// <summary>
        /// 商户订单号
        /// </summary>
        public string OutTradeNo { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 商户分账单号（拆单分账时有效，必填，同延迟分账中的outSplitTradeNo）
        /// </summary>
        public string? OutSplitTradeNo { get; set; }

        /// <summary>
        /// 申请退款金额（单位分 必须小于等于原订单支付成功金额，必须大于0。拆单分账必须小于等于子订单金额。）
        /// </summary>
        public long RefundAmount { get; set; }

        /// <summary>
        /// 原订单金额（单位分）
        /// </summary>
        public long Amount { get; set; }

        /// <summary>
        /// 商品订单信息
        /// </summary>
        public EpaylinksOrderInfo? OrderInfo { get; set; }

        /// <summary>
        /// 退款申请说明
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 退款结果通知地址
        /// </summary>
        public string NotifyUrl { get; set; }

        /// <summary>
        /// 分账退款信息列表
        /// </summary>
        public List<SplitInfoList>? SplitInfoList { get; set; }

        /// <summary>
        /// 退款路径
        /// </summary>
        public List<ReturnToList>? ReturnToList { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string NonceStr { get; set; }

    }

    /// <summary>
    /// 分账退款信息列表 中每个元素为一个分账信息，其字段如下，需保证所有amount的和等于申请退款金额
    /// </summary>
    public class SplitInfoList
    {
        /// <summary>
        /// 分账目标商户编号
        /// </summary>
        public string CustomerCode { get; set; }


        /// <summary>
        /// 分账金额 分账金额，单位分使用的币种必须不对应支付交易单的币种一致；可以大于等于0
        /// </summary>
        public long Amount { get; set; }

        /// <summary>
        /// 退款路径
        /// </summary>
        public string ReturnTo { get; set; }


    }

    /// <summary>
    /// 退款路径 中每个元素为一个退款路径信息
    /// </summary>
    public class ReturnToList
    {
        /// <summary>
        /// 分账金额 退款金额，单位分使用的币种必须不对应支付交易单的币种一致；可以大于等于0
        /// </summary>
        public long Amount { get; set; }

        /// <summary>
        /// 退款路径
        /// </summary>
        public string ReturnTo { get; set; }
    }

    /// <summary>
    /// 退款响应对象
    /// </summary>
    public class RefundResponse : EpaylinksResponseDto
    {

        /// <summary>
        /// 商户退款单号
        /// </summary>
        public string OutRefundNo { get; set; }

        /// <summary>
        /// 商户订单号
        /// </summary>
        public string OutTradeNo { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 申请退款金额 单位分
        /// </summary>
        public long RefundAmount { get; set; }

        /// <summary>
        /// 原订单金额（单位分）
        /// </summary>
        public long OrgiAmount { get; set; }

        /// <summary>
        /// 退款手续费 单位分，退款成功时必需分账退款时等亍各分账条目退款手续贶乊和
        /// </summary>
        public long ProcedureFee { get; set; }

        /// <summary>
        /// 退回收单手续费 单位分，退款成功时必需分账退款时等亍各分账条目退回收单手续费之和
        /// </summary>
        public long BackpayProcedurefee { get; set; }

        /// <summary>
        /// 退回分账手续费 单位分，分账退款成功时必需
        /// </summary>
        public long BackSplitProcedureFee { get; set; }

        /// <summary>
        /// 随机字符串 随机字符串，推荐随机数生成算法产生
        /// </summary>
        public string NonceStr { get; set; }
    }

    /// <summary>
    /// 退款结果查询请求对象
    /// </summary>
    public class RefundResultQueryRequestDto
    {
        /// <summary>
        /// 商户编号
        /// </summary>
        public string? CustomerCode { get; set; }

        /// <summary>
        /// 商户退款单号(必传)
        /// </summary>
        public string OutRefundNo { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string? NonceStr { get; set; }

    }

    /// <summary>
    /// 退款结果查询响应对象
    /// </summary>
    public class RefundResultQueryResponseDto: EpaylinksResponseDto
    {
        /// <summary>
        /// 商户编号
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 商户退款单号
        /// </summary>
        public string OutRefundNo { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 商户分账单号
        /// </summary>
        public string? OutSplitTradeNo { get; set; }

        /// <summary>
        /// 上游订单号
        /// </summary>
        public string? ChannelTradeNo { get; set; }

        /// <summary>
        /// 申请退款金额
        /// </summary>
        public long? RefundAmount { get; set; }

        /// <summary>
        /// 原订单金额
        /// </summary>
        public long? Amount { get; set; }

        /// <summary>
        /// 退款执行结果
        /// </summary>
        public string? RefundState { get; set; }

        /// <summary>
        /// 退款成功时间
        /// </summary>
        public string? RefundTime { get; set; }

        /// <summary>
        /// 退款手续费
        /// </summary>
        public long? ProcedureFee { get; set; }

        /// <summary>
        /// 退回收单手续费
        /// </summary>
        public long? BackpayProcedurefee { get; set; }

        /// <summary>
        /// 退回分账手续费
        /// </summary>
        public long? BackSplitProcedureFee { get; set; }

        /// <summary>
        /// 优惠退款详情
        /// </summary>
        public string? RefundDetail { get; set; }

        /// <summary>
        /// 分账退款信息列表
        /// </summary>
        public string? SplitInfoList { get; set; }

        /// <summary>
        /// 退款路径
        /// </summary>
        public string? ReturnToList { get; set; }

        /// <summary>
        /// 保留信息
        /// </summary>
        public string? Reserved { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string NonceStr { get; set; }
    }

    /// <summary>
    /// 退款结果异步通知响应对象
    /// </summary>
    public class RefundResultNotificationRequestDto
    {
        /// <summary>
        /// 商户编号
        /// </summary>
        public string CustomerCode { get; set; }

        /// <summary>
        /// 商户退款单号
        /// </summary>
        public string OutRefundNo { get; set; }

        /// <summary>
        /// 易票联订单号
        /// </summary>
        public string TransactionNo { get; set; }

        /// <summary>
        /// 商户分账单号
        /// </summary>
        public string? OutSplitTradeNo { get; set; }

        /// <summary>
        /// 上游订单号
        /// </summary>
        public string? ChannelTradeNo { get; set; }

        /// <summary>
        /// 申请退款金额
        /// </summary>
        public long? RefundAmount { get; set; }

        /// <summary>
        /// 原订单金额
        /// </summary>
        public long? Amount { get; set; }

        /// <summary>
        /// 退款执行结果（00=退款成功，01=退款失败，03=退款1处理中）
        /// </summary>
        public string? PayState { get; set; }

        /// <summary>
        /// 退款成功时间
        /// </summary>
        public string? PayTime { get; set; }

        /// <summary>
        /// 退款手续费
        /// </summary>
        public long? ProcedureFee { get; set; }

        /// <summary>
        /// 退回收单手续费
        /// </summary>
        public long? BackpayProcedurefee { get; set; }

        /// <summary>
        /// 退回分账手续费
        /// </summary>
        public long? BackSplitProcedureFee { get; set; }

        /// <summary>
        /// 优惠退款详情
        /// </summary>
        public string? RefundDetail { get; set; }

        /// <summary>
        /// 分账退款信息列表
        /// </summary>
        public string? SplitInfoList { get; set; }

        /// <summary>
        /// 退款路径
        /// </summary>
        public string? ReturnToList { get; set; }

        /// <summary>
        /// 保留信息
        /// </summary>
        public string? Reserved { get; set; }

        /// <summary>
        /// 随机字符串
        /// </summary>
        public string NonceStr { get; set; }

    }
        
}
